/*
 * License: Copyright (c) Huawei Technologies Co., Ltd. 2012-2019. All rights reserved.
 * Description: video eccode
 * Date: 2020-01-07 09:50:36
 * LastEditTime : 2020-02-13 09:37:02
 */


#ifndef VENCENGINE_H
#define VENCENGINE_H
#include <map>
#include <string>
#include <vector>
#include "dvpp/dvpp_config.h"
#include "dvpp/idvppapi.h"
#include "dvpp/Venc.h"
#include "hiaiengine/api.h"
#include "hiaiengine/engine.h"
#include "hiaiengine/multitype_queue.h"
#include "trans_data.h"
using namespace hiai;
#define INPUT_SIZE 1
#define OUTPUT_SIZE 1

class VencEngine : public Engine {
public:
    ~VencEngine();
    HIAI_StatusT EncodeYuv2Video(std::shared_ptr<TransData> transData);
    HIAI_StatusT VencInit(std::shared_ptr<TransData> transData);
    static void VencCallBack(struct VencOutMsg* vencOutMsg, void* userData);
    uint64_t GetCurentTimeStamp();
    HIAI_DEFINE_PROCESS(INPUT_SIZE, OUTPUT_SIZE);

private:
    /* define VENC handle */
    int32_t vencHandle = -1;
    struct VencConfig vencConfig;

    /* transfer data between the callback functiong and main process */
    queue<std::shared_ptr<TransData>> encodedQueue;

    uint64_t frameIndex = 0;

    struct timeval currentTimeval;

    uint64_t initialTimeStamp;
};
#endif
